package com.lk.ii.service.impl;

import java.util.List;
import com.lk.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lk.ii.mapper.IiEncyclopediaMapper;
import com.lk.ii.domain.IiEncyclopedia;
import com.lk.ii.service.IIiEncyclopediaService;
import com.lk.common.core.text.Convert;

/**
 * 百科Service业务层处理
 * 
 * @author lk
 * @date 2021-02-22
 */
@Service
public class IiEncyclopediaServiceImpl implements IIiEncyclopediaService 
{
    @Autowired
    private IiEncyclopediaMapper iiEncyclopediaMapper;

    @Override
    public List<IiEncyclopedia> getEncyclopediaPageList(Long pageSize, Long offset)
    {
        return iiEncyclopediaMapper.getEncyclopediaPageList(pageSize, offset);
    }

    /**
     * 查询百科
     * 
     * @param id 百科ID
     * @return 百科
     */
    @Override
    public IiEncyclopedia selectIiEncyclopediaById(Long id)
    {
        return iiEncyclopediaMapper.selectIiEncyclopediaById(id);
    }

    /**
     * 查询百科列表
     * 
     * @param iiEncyclopedia 百科
     * @return 百科
     */
    @Override
    public List<IiEncyclopedia> selectIiEncyclopediaList(IiEncyclopedia iiEncyclopedia)
    {
        return iiEncyclopediaMapper.selectIiEncyclopediaList(iiEncyclopedia);
    }


    /**
     * 前台的关键查询
     * @param name 关键字
     * @return
     */
    @Override
    public List<IiEncyclopedia> findByKeyword(String name) {
        List<IiEncyclopedia> byKeyword = iiEncyclopediaMapper.findByKeyword(name);
        return byKeyword;
    }

    /**
     * 新增百科
     * 
     * @param iiEncyclopedia 百科
     * @return 结果
     */
    @Override
    public int insertIiEncyclopedia(IiEncyclopedia iiEncyclopedia)
    {
        iiEncyclopedia.setCreateTime(DateUtils.getNowDate());
        return iiEncyclopediaMapper.insertIiEncyclopedia(iiEncyclopedia);
    }

    /**
     * 修改百科
     * 
     * @param iiEncyclopedia 百科
     * @return 结果
     */
    @Override
    public int updateIiEncyclopedia(IiEncyclopedia iiEncyclopedia)
    {
        iiEncyclopedia.setUpdateTime(DateUtils.getNowDate());
        return iiEncyclopediaMapper.updateIiEncyclopedia(iiEncyclopedia);
    }

    /**
     * 删除百科对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteIiEncyclopediaByIds(String ids)
    {
        return iiEncyclopediaMapper.deleteIiEncyclopediaByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除百科信息
     * 
     * @param id 百科ID
     * @return 结果
     */
    @Override
    public int deleteIiEncyclopediaById(Long id)
    {
        return iiEncyclopediaMapper.deleteIiEncyclopediaById(id);
    }


}
